import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { AStarPoint } from "../../../scene/map/AStarPoint";
import { EDragonDirection } from "../../../../../Message/Public/EDragonDirection";
type int = number;
//class LGXBDirection
    
    export  class LGXBDirection
    {
        

        public getDirectonIcon(arg1: int, arg2: Boolean): Object /* flash.display.Bitmap */
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            if (!this.icons) 
            {
                loc1 = ObjCreate.createBitmap(ImagesConst.LGXB_top, 0, 0, null);
                loc2 = ObjCreate.createBitmap(ImagesConst.LGXB_down, 0, 0, null);
                loc3 = ObjCreate.createBitmap(ImagesConst.LGXB_left, 0, 0, null);
                loc4 = ObjCreate.createBitmap(ImagesConst.LGXB_right, 0, 0, null);
                this.icons = new Map<any, any> /* flash.utils.Dictionary */(false);
                this.icons[LGXBDirection.toLeft] = loc3;
                this.icons[LGXBDirection.toRight] = loc4;
                this.icons[LGXBDirection.toTop] = loc1;
                this.icons[LGXBDirection.toDown] = loc2;
                this.icons[LGXBDirection.toLeft + 100] = new Object /* flash.display.Bitmap */(loc3.bitmapData);
                this.icons[LGXBDirection.toRight + 100] = new Object /* flash.display.Bitmap */(loc4.bitmapData);
                this.icons[LGXBDirection.toTop + 100] = new Object /* flash.display.Bitmap */(loc1.bitmapData);
                this.icons[LGXBDirection.toDown + 100] = new Object /* flash.display.Bitmap */(loc2.bitmapData);
            }
            if (arg2) 
            {
                return this.icons[arg1 + 100];
            }
            return this.icons[arg1];
        }

        public getDirectionArrowByFlag(arg1: int): Object /* flash.display.Bitmap */
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            if (!this.arrows) 
            {
                loc1 = ObjCreate.createBitmap(ImagesConst.LGXB_ArrowUp, 0, 0, null);
                loc2 = ObjCreate.createBitmap(ImagesConst.LGXB_ArrowDown, 0, 0, null);
                loc3 = ObjCreate.createBitmap(ImagesConst.LGXB_ArrowLeft, 0, 0, null);
                loc4 = ObjCreate.createBitmap(ImagesConst.LGXB_ArrowRight, 0, 0, null);
                this.arrows = new Map<any, any> /* flash.utils.Dictionary */(false);
                this.arrows[LGXBDirection.toLeft] = loc3;
                this.arrows[LGXBDirection.toRight] = loc4;
                this.arrows[LGXBDirection.toTop] = loc1;
                this.arrows[LGXBDirection.toDown] = loc2;
                this.arrows[LGXBDirection.toNone] = new Object /* flash.display.Bitmap */();
            }
            return this.arrows[arg1];
        }

        public getDirectionPoint(arg1: int): Object /* flash.geom.Point */
        {
            if (!this.sidePoints) 
            {
                this.sidePoints = new Map<any, any> /* flash.utils.Dictionary */(false);
                this.sidePoints[LGXBDirection.toLeft] = new Object /* flash.geom.Point */(0, -1);
                this.sidePoints[LGXBDirection.toRight] = new Object /* flash.geom.Point */(0, 1);
                this.sidePoints[LGXBDirection.toTop] = new Object /* flash.geom.Point */(-1, 0);
                this.sidePoints[LGXBDirection.toDown] = new Object /* flash.geom.Point */(1, 0);
            }
            var loc1=this.sidePoints[arg1];
            return loc1;
        }

        public getOpersiteSide(arg1: int): int
        {
            if (arg1 == LGXBDirection.toLeft) 
            {
                return LGXBDirection.toRight;
            }
            if (arg1 == LGXBDirection.toRight) 
            {
                return LGXBDirection.toLeft;
            }
            if (arg1 == LGXBDirection.toTop) 
            {
                return LGXBDirection.toDown;
            }
            if (arg1 == LGXBDirection.toDown) 
            {
                return LGXBDirection.toTop;
            }
            return -1;
        }

        public getDirectPointByTwoPoint(arg1: AStarPoint, arg2: AStarPoint): int
        {
            if (arg1.x != arg2.x) 
            {
                if (arg1.y == arg2.y) 
                {
                    if (arg2.x > arg1.x) 
                    {
                        return LGXBDirection.toDown;
                    }
                    if (arg2.x < arg1.x) 
                    {
                        return LGXBDirection.toTop;
                    }
                }
            }
            else 
            {
                if (arg2.y > arg1.y) 
                {
                    return LGXBDirection.toRight;
                }
                if (arg2.y < arg1.y) 
                {
                    return LGXBDirection.toLeft;
                }
            }
            throw new Error("移动路径有误 <LGXBDirection.as>");
        }

        public static /* const */toLeft: int=EDragonDirection._EDragonDirectionWest;

        public static /* const */toRight: int=EDragonDirection._EDragonDirectionEast;

        public static /* const */toTop: int=EDragonDirection._EDragonDirectionNorth;

        public static /* const */toDown: int=EDragonDirection._EDragonDirectionSouth;

        public static /* const */toNone: int=-1;

        public static /* const */instance: LGXBDirection=new LGXBDirection();

        /* internal */ /* var */arrows: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */icons: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */sidePoints: Map<any, any> /* flash.utils.Dictionary */;
    }
